﻿using System;

namespace ZyGame
{
    public sealed class ByteVarable : Varable<byte>
    {
        public ByteVarable(byte value)
        {
            this.value = value;
        }

        public static implicit operator byte(ByteVarable varable)
        {
            return varable.value;
        }

        public static explicit operator ByteVarable(byte varable)
        {
            return new ByteVarable(varable);
        }

        public static ByteVarable operator +(ByteVarable left, ByteVarable right)
        {
            left.value = (byte)Math.Clamp(left.value + right.value, byte.MinValue, byte.MaxValue);
            return left;
        }

        public static ByteVarable operator -(ByteVarable left, ByteVarable right)
        {
            left.value = (byte)Math.Clamp(left.value - right.value, byte.MinValue, byte.MaxValue);
            return left;
        }

        public static ByteVarable operator *(ByteVarable left, ByteVarable right)
        {
            left.value = (byte)Math.Clamp(left.value * right.value, byte.MinValue, byte.MaxValue);
            return left;
        }

        public static ByteVarable operator /(ByteVarable left, ByteVarable right)
        {
            left.value = (byte)Math.Clamp(left.value / right.value, byte.MinValue, byte.MaxValue);
            return left;
        }

        public static bool operator ==(ByteVarable left, ByteVarable right)
        {
            return left.value == right.value;
        }

        public static bool operator !=(ByteVarable left, ByteVarable right)
        {
            return left.value != right.value;
        }
    }
}
